// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import $ from 'jquery'

Vue.config.productionTip = false;

Vue.use(iView);
import axios from 'axios';
Vue.prototype.axios = axios;
// Vue.prototype.siteUrl = "http://175.102.18.7:5202/api"
// Vue.prototype.adminUrl = "http://175.102.18.7:5202/admin"
//Vue.prototype.adminUrl ="http://10.58.110.55:5202/admin"
//Vue.prototype.siteUrl = "http://10.58.110.55:5202/api";
Vue.prototype.siteUrl ="http://106.15.200.244:5202/api"
Vue.prototype.adminUrl ="http://106.15.200.244:5202/admin"
/* eslint-disable no-new */
//Vue.http.options.emulateJSON = true;

router.beforeEach((to, from, next) => {
  if (from.path === '/' && to.path === '/share') {
    next('/personal');
  }else if (to.path === '/share') {
    let level = localStorage.getItem("level");
    let uid = localStorage.getItem("uid");
    let math = Math.floor(Math.random() * 1000000000);
    //console.log(to.fullPath + "  " + from.fullPath); 
    location.href = "http://m.mirrorcare.cn/register.html?level="+level+"&higher_up="+uid+"&math="+math;  
  }
  let aid = localStorage.getItem("aid");
  if (to.name !== 'index' && to.name !== 'admin' && aid===null && to.name !== 'updateIndex' && to.name !== 'updatePassword' && to.name !== 'forgetPassword'
  && to.name !== 'register' && to.name !== 'registerFirst' && to.name !== 'registerSecond' && to.name !== 'registerThird' && to.name !== 'rakeBack'
  && to.name !== 'xFRebate' && to.name !== 'zSRebate' && to.name !== 'teamZSReward' && to.name !== 'teamXFReward' && to.name !== 'checkError'
  && to.name !== 'checkSuccess' && to.name !== 'allIncome' && to.name !== 'mouthIncome' && to.name !== 'personal' && to.name !== 'accountManagement'
  && to.name !== 'commonProblem' && to.name !== 'message' && to.name !== 'myServices' && to.name !== 'myWallet' && to.name !== 'inviteFriends'
  && to.name !== 'aboutUs' && to.name !== 'problemDetail' && to.name !== 'messageDetail' && to.name !== 'inviteAgent' && to.name !== 'agentDetail'
  && to.name !== 'consumeRecord' && to.name !== 'empty' && to.name !== 'certificate' && to.name !== 'share' && to.name !== 'inviteCode' && to.name !== 'applyCash'){
    next({name:'admin'});
    return;
  }
  next();
});

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
